package com.note7_10;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Click {

	public static void main(String[] args) {
		
		Socket s = null;
		try {
			s = new Socket("127.0.0.1",8090);
			System.out.println("1、查询当前气温");
			System.out.println("2、查询当前风力");
			System.out.println("3、查询当前pm2.5");
			System.out.println("4、查询当前湿度");
			System.out.println("5、显示所有");
			System.out.println("6、退出");
			
			InputStream is = s.getInputStream();
			OutputStream os = s.getOutputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(is));
			PrintWriter pw = new PrintWriter(os);
			Scanner in = new Scanner(System.in);
			while(true){
				System.out.println("欢迎来到天气管理系统！请选择你的操作：");
				int i = in.nextInt();
				pw.println(i);
				pw.flush();
				String str = br.readLine();
				if(i == 6){
					break;
				}else{
					System.out.println(str);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (s != null)
				try {
					s.close();
					System.out.println("成功退出");
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
	}
}
